import { BaseWindow } from "../../../../component/window/BaseWindow";
import { ILayer } from "../../../../mvc/interfaces/ILayer";
import { Language } from "../../../../../extend/language/Language";
import { ObjCreate } from "../../common/ObjCreate";
import { SGuildPartyOpen } from "../../../../../Message/Game/SGuildPartyOpen";
import { GameDefConfig } from "../../../resource/GameDefConfig";
import { GuildUtil } from "../info/GuildUtil";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { Cache } from "../../../cache/Cache";
import { GButton } from "../../../../../com/mui/controls/GButton";
//class GuildPartyJoinWindow
    
    export  class GuildPartyJoinWindow extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            this.setSize(300, 160);
            this.titleHeight = 28;
            this.title = Language.getString(20055);
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            ObjCreate.createBg(17, 39, 265, 110, this);
            this._tipTxt = ObjCreate.createTextField("", 30, 50, 237, 50, this);
            this._tipTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._tipTxt.wordWrap = true;
            this._tipTxt.multiline = true;
            this._joinBtn = ObjCreate.createGButton(Language.getString(57439), 115, 110, 70, 28, this);
            this._joinBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onJoinBtnClickHandler);
            return;
        }

        public updateByGuildPartyOpen(arg1: SGuildPartyOpen): void
        {
            var loc1=null;
            var loc2=null;
            if (arg1) 
            {
                loc1 = GameDefConfig.instance.getPositionName(arg1.position);
                loc2 = GuildUtil.getGuildPartyTypeName(arg1.type.__value);
                this._tipTxt.htmlText = Language.getStringByParam(57440, arg1.hostName, loc1, loc2);
            }
            return;
        }

        /* internal  */onJoinBtnClickHandler(arg1: Object /* flash.events.Event */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.GuildEnterManor, {"guildId": Cache.instance.guild.myGuildInfo.guildId, "useContribution": false}));
            this.hide();
            return;
        }

        /* internal */ /* var */_tipTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_joinBtn: GButton;
    }
